fun dump(b: Byte) {
    var v = b.toInt()
    for (i in 0..7) {
        if ((v and 0x80) > 0) {
            print('1')
        } else {
            print('0')
        }
        v = v shl 1
    }
    println()
}

fun dump16(v: Int) {
    var value = v
    for (i in 0..15) {
        if (i % 4 == 0) {
            print(",")
        }
        if ((value and 0x8000) > 0) {
            print('1')
        } else {
            print('0')
        }
        value = value shl 1
    }
}

fun main() {
    for (i in -128..127) {
        print("$i:\t\t\t")
//        dump(i.toByte())
        dump16(i)
        print("\t")
        dump16(i + 0x80)
        print("\t")
        dump16(i and 0x7f)
        println()
    }
}